﻿using System;

namespace Codeplex.Data.Internal
{
    internal static class Precondition
    {
        public static void NotNull(object obj, string parameterName = "", string message = "")
        {
            if (obj == null) throw new ArgumentNullException(parameterName, message);
        }

        public static void NotNullAll(params object[] objects)
        {
            foreach (var obj in objects)
            {
                if (obj == null) throw new ArgumentNullException();
            }
        }

        public static void NotNullOrEmpty(string value, string parameterName = "", string message = "")
        {
            if (value == null) throw new ArgumentNullException(parameterName, message);
            if (value == "") throw new ArgumentException(message, parameterName);
        }

        public static void NotNullOrEmptyAll(params string[] values)
        {
            foreach (var value in values)
            {
                if (value == null) throw new ArgumentNullException();
                if (value == "") throw new ArgumentException();
            }
        }

        public static void Requires(bool condition, string parameterName = "", string message = "")
        {
            if (!condition) throw new ArgumentException(message, parameterName);
        }
    }
}
